package com.happy.controller;

import com.happy.entity.PaperEntity;
import com.happy.service.IPaperService;
import com.happy.util.ResultBody;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: Wuzh
 * @Description:
 * @Date Created in 21:49 2021/1/23
 * @return
 */
@RestController
@RequestMapping ("/paper")
@CrossOrigin (value = "*", maxAge = 3600)
public class PaperController {


    @Resource
    private IPaperService iPaperService;

    @RequestMapping ("/queryList")
    public ResultBody<PaperEntity> paperList (PaperEntity paperEntity) {
        List<PaperEntity> paperEntities = iPaperService.queryList ( paperEntity );
        return ResultBody.success ( paperEntities, paperEntities.size () );
    }


    @RequestMapping ("/addSingle")
    public ResultBody<PaperEntity> addSingle (@RequestBody PaperEntity paperEntity) {
        paperEntity = iPaperService.addSingle ( paperEntity );
        return ResultBody.success ( paperEntity );
    }

}
